<template>
	<view>
		<view v-if="!dataListIsEmpty" class="dataListView">
			<view class="item" v-for="(item, index) in dataList" :key="index">
				<view class="item-left">
					<view class="price-view util-font-medium">￥{{parseInt(item.amount)/100.}}</view>
					<view class="time-view util-font-regular">{{item.createTime}}</view>
				</view>
				<view class="item-right util-font-regular">
					<view v-if="item.status == 0" class="item-status">审核中</view>
					<view v-if="item.status == 1" class="item-status">审核完成，正在发放</view>
					<view v-if="item.status == 2" class="item-status">提现完成</view>
					<view v-if="item.status == 3" class="item-status" style="margin-top: 0;">审核失败，金额已退回</view>
					<view v-if="item.status == 3" class="item-reason">{{item.reason}}</view>
				</view>
			</view>
			<uni-load-more v-if="currentPage == totalPage" :status="'none'" @clickLoadMore="loadMore"></uni-load-more>
			<uni-load-more v-else :status="'more'" @clickLoadMore="loadMore"></uni-load-more>
		</view>
		<view v-else class="empty-view">
			<image class="empty-image" src="../../static/noData.png" mode="aspectFit"></image>
			<view class="empty-title util-font-medium">暂无数据</view>
		</view>	
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				dataList: [],
				dataListIsEmpty: false,
				currentPage: 1,
				totalPage: 1,
			}
		},
		onLoad() {
			this.loadData()
		},
		onPullDownRefresh() {
			this.currentPage = 1
			this.loadData()
		},
		onReachBottom() {
			if (this.currentPage == this.totalPage) {
				
			}else{
				this.currentPage++
				this.loadData()
			}
		},
		methods: {
			loadData: function(){
				var that = this
				that.sendRequest({
					url: 'app/appBrokerageWithdrawRecords/page',
					method: 'POST',
					header: that.$urlRequest.getHeader('token'),
					data: {
						userId: uni.getStorageSync('userInfo').id,
						limit: 5,
						page: that.currentPage
					},
					success: function(res){
						
						that.totalPage = res.data.pages
						that.dataList = that.dataList.concat(res.data.records)
						
						if (that.dataList.length == 0) {
							that.dataListIsEmpty = true
						}else{
							that.dataListIsEmpty = false
						}
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}
	.item {
		overflow: hidden;
		background-color: #FFFFFF;
		width: 690rpx;
		height: 110rpx;
		padding: 0 30rpx;
		border-bottom: 2rpx solid #F1F1F1;
	}
	.item-left {
		height: 110rpx;
		float: left;
		max-width: 345rpx;
	}
	.price-view {
		height: 55rpx;
		line-height: 55rpx;
		font-size: 38rpx;
		color: #333333;
		margin-top: 10rpx;
	}
	.time-view {
		height: 30rpx;
		line-height: 30rpx;
		color: #999999;
		font-size: 24rpx;
	}
	.item-right {
		height: 110rpx;
		float: right;
		max-width: 345rpx;
		padding: 10rpx 0;
		text-align: right;
	}
	.item-status {
		font-size: 34rpx;
		margin-top: 20rpx;
	}
	.item-reason {
		font-size: 24rpx;
		color: #999999;
	}
	
	/* 空数据提示 */
	.empty-view {
		text-align: center;
		margin-top: 200upx;
	}
	
	.empty-image {
		width: 300upx;
		height: 210upx;
	}
	
	.empty-title {
		color: #999999;
		font-size: 32upx;
		margin-top: 30upx;
	}
</style>
